﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public class Health:TankComponent {
    [Header("血量")]
    public int health;
    public int maxHp;

    [Header("血条")]
    public Slider hpSlider;

    public int Hp
    {
        get { return health; }
        set {
            if (value == 0)
            {   //If the tank's health will go under 0 when it gets damaged.
                Die();              //Kill the tank since its health will be under 0.
            }
            else
            {                   //Otherwise...
                health = value ;      //Subtract the dmg from the tank's health.
                hpSlider.value = health /(float) maxHp;
            }
        }
    }

    private void Die()
    {
        
    }
    public void Injured(int value)
    {
        health -= value;
    }
    public void Start()
    {

    }
    
}
